package com.dongdongshop.Email;

import com.dongdongshop.pojo.ToEmail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class SendMailServiceImpl implements SendMailService {


    @Autowired
    private JavaMailSender senderMail;


    @Value("${spring.mail.username}")
    private String username;

    //普通邮件
    @Override
    public void sendMail(ToEmail te) {
        SimpleMailMessage message=new SimpleMailMessage();

        //谁发
        message.setFrom(username);
        //谁收
        message.setTo(te.getTos());
        //主题
        message.setText(te.getSubject());
        //内容
        message.setText(te.getContent());
        //调用街都发送
        senderMail.send(message);
    }
}
